/**
 * @Author：ming
 * @Date：2023/10/25 3:42 PM
 * @Filename：Lc168
 */

/**
 * @author ming
 */
public class Lc168 {
    public String convertToTitle(int columnNumber) {
        //本质是十进制转化为26进制
        StringBuilder sb = new StringBuilder();
        int temp =0;
        char[] c = new char[26];
        char a = 'A';
        for (int i = 0; i < 26; i++) {
            c[i] =(char) (a+i);
        }
        while (columnNumber>26){
            temp = columnNumber%26;
            columnNumber /=26;
            sb.append(c[temp-1]);
        }
        if(columnNumber!=0){
            sb.append(c[columnNumber-1]);
        }
        
        StringBuilder reverse = sb.reverse();
        return  reverse.toString();
    }
}
